﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MensUnoShop.Models.ViewModels.OrderViewModel>" %>
<%@ Import Namespace="MensUnoShop.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	men'suno SHOP
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
    var ismaga = false;
    if (Model.OD.MLIST.Any(m => m.TYPE == Config.MarketType.Mangazine))
        ismaga = true;
%>

<div class="CART_CONTENT">
<img src="/Content/page_img/cart_content_top.gif" />
<div class="CART_TITLE">
<h1>購物車</h1>
<span class="CART_BT_FAVORITE"><a href="/member/my_favorite">最愛商品清單</a></span>
<br class="CLEAR" />
</div>
<div class="CART_FORM">
  <table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
      <td width="114"><div align="center"></div></td>
      <td width="97"><div align="center"></div></td>
      <td width="394"><div align="left">商品<br />
        Item </div></td>
      <td width="62"><div align="center"><%if(ismaga){ %>期數<br />issues<%}else{ %>顏色<br />Color<%} %></div></td>
      <td width="62"><div align="center"> 單價<br />
        Price </div></td>
      <td width="53"><div align="center"> 數量<br />
        Quantity
      </div></td>
      <td width="130"><div align="center">金額小計<br />
        Total price</div></td>
    </tr>
   <% foreach (var sc in Model.OD.MLIST.Where(m => m.TYPE != Config.MarketType.Combo))
      {%>
  <tr>
    <td><div align="center"></div></td>
    <td><div align="center"><img src="<%:sc.IMG %>" width="75" height="75" /></div></td>
    <td valign="top"><%:sc.SN %><br /><%:sc.TITLE %><br />
      <span class="PRODUCT3_HOT_POINT"><%:sc.DISCOUNTNOTE %></span></td>
    <td><div align="center"><%:sc.COLOR %></div></td>
    <td><div align="center">NT$<%:sc.SINGLEPRICE %></div></td>
    <td><div align="center"><%:sc.AMOUNT%></div></td>
    <td><div align="center">NT$<%:sc.PRICE %></div></td>
    <td><div align="center"></div></td>
  </tr>
  <%} %>
  <% foreach(var sc in Model.OD.MLIST.Where(m=>m.TYPE==Config.MarketType.Combo).GroupBy(m=>m.COMBOID)){
         int i = 0;
         int pices = sc.Count();
         int divv = pices / sc.FirstOrDefault(s => s.AMOUNT > 0).AMOUNT;
         foreach (var s in sc)
         {
             string cs = string.Empty;
             string cs1 = string.Empty;
             string single = string.Empty;
             string amount = string.Empty;
             string total = string.Empty;

             if (i != sc.Count() - 1)
             {
                 cs = "style=\"border-bottom:none;\"";
                 cs1 = "style=\"border-bottom:none;\"";
             }
             if ((i + 1) % divv == 0)
             {
                 cs = "style=\"border-bottom:none;\"";
                 cs1 = string.Empty;
             }
             
             if (i == 0)
             {
                 single = "NT$"+s.SINGLEPRICE.ToString();
                 amount = s.AMOUNT.ToString();
                 total = "NT$"+s.PRICE.ToString();
             }
             else
             {
                 single = string.Empty;
                 amount = string.Empty;
                 total = string.Empty;
             }
  %>
  <tr>
    <td <%=cs %>><div align="center"></div>
    </td>
    <td <%=cs1 %>><div align="center"><img src="<%:s.IMG %>" width="75" height="75" /></div></td>
    <td <%=cs1 %> valign="top"><%:s.SN%><br /><%:s.TITLE%><br />
      <span class="PRODUCT3_HOT_POINT"><%:s.DISCOUNTNOTE%></span></td>
    <td <%=cs1 %>><div align="center"><%:s.COLOR%></div></td>
    <td <%=cs %>><div align="center"><%:single%></div></td>
    <td <%=cs %>><div align="center"><%:amount%></div></td>
    <td <%=cs %>><div align="left">&nbsp;&nbsp;<%:total%></div></td>
    <td <%=cs %>><div align="center"></div></td>
  </tr>
  <%
             i++;
         }
     } %>
    
  </table>
  <table width="850" border="0" align="center" cellpadding="0" cellspacing="0">
  <%foreach (var d in Model.OD.DSKLIST)
    { %>
  <tr>
    <td style="width:30px;"></td>
    <td style="width:700px;text-align:left"><%:d.TITLE %></td>
    <td style="text-align:left">-NT$<%:d.DEPRICE%></td>
  </tr>
  <%} %>
  <tr>
    <td></td>
    <td><%if (Model.OD.SHIPPINGWAY == 0 && !ismaga){%>台灣地區免運費Taiwan(郵局掛號、存局候領、超商取貨)<%} %>
        <%else{%>
            寄送地區僅限台灣及離島地區，海外購買請洽客服：886-2-27316690 ext.105或電郵至<a href="hung@chicgroup.com.tw">hung@chicgroup.com.tw</a>
        <%} %>
        <%if (Model.OD.SHIPPINGWAY == 1){%>亞洲Asia(EMS/國際快捷郵件)<%} %>
        <%if (Model.OD.SHIPPINGWAY == 2){%>美洲、歐洲地區America &amp; Europe(EMS國際快捷)<%} %>
        <%if (Model.OD.SHIPPINGWAY == 3){%>中美洲、非洲Central America &amp; Africa(EMS國際快捷)<%} %>
   </td>
    <td>&nbsp;NT$<%:Model.OD.DELIVERYCOST %></td>
  </tr>
  <tr>
    <td bgcolor="#CCCCCC">&nbsp;</td>
    <td bgcolor="#CCCCCC"><div align="right"><span class="FORM_TOTAL2">總計金額Total</span></div></td>
    <td bgcolor="#CCCCCC"><div align="left" class="FORM_TOTAL2">NT$<%:Model.OD.PAYPRICE %></div></td>
  </tr>
</table>
    <div class="BUYER_INFO">
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td width="14%" class="FONT_GREEN"><div align="right"> <span class="MEMBER_TITLE1_POINT2">＊</span>商品寄送資訊<br />
            Receiver</div></td>
          <td>姓名Name：
            <%:Model.OD.RECIPIENT.NAME %>
            <%if(Model.OD.RECIPIENT.SEX){ %>小姐<%}else {%>先生<%} %>　電話Tel： <%:Model.OD.RECIPIENT.TEL %>           </td>
        </tr>
        <tr>
           <td>&nbsp;</td>
          <td>寄送地址add：<%:Model.OD.RECIPIENT.ZIP + " " + Model.OD.RECIPIENT.CITY + Model.OD.RECIPIENT.AREA + Model.OD.RECIPIENT.ADDRESS + "( " + Model.OD.RECIPIENT.COUNTRY + " )"%><br /></td>
        </tr>
        <tr>
          <td><div align="right">發票資訊：</div></td>
          <td><%:Config.InvoiceType[Model.OD.INVOICETYPE] %>　<%if (Model.OD.INVOICETYPE == 1)
                                                               { %>抬頭：<%:Model.OD.INVOICETITLE ?? ""%>　統一編號：<%:Model.OD.INVOICESERIAL ?? ""%><%} %></td>
        </tr>
        <tr>
          <td valign="top"><div align="right" class="FONT_GREEN">客戶意見欄<br />
              Customer  opinion</div></td>
          <td><%:Model.OD.RECIPIENT.CUSTOMER %></td>
        </tr>
        <tr>
          <td>&nbsp;</td>
          <td><div align="right">
            <form action="/order/pay/<%:Model.OD.SCGUID %>" method="post"><input type="hidden" name="scck" value="<%:Model.SCCK %>" />
                        <%if (!ismaga)
            { %>
                <input type="button" name="button" value="回返購物車 Shopping Cart" onclick="location.href='/market/c'"/>
              <%}
            else
            { %>
                <input type="button" name="button" value="回上一頁 Back" onclick="history.back();"/>
              <%} %>　<input type="submit" value="確認訂購資訊 Confirm"/>　
              </form>
          </div></td>
        </tr>
      </table>
    </div>
    <%Html.RenderPartial("/Views/Shared/ReturnText.ascx", ismaga); %>
    </div><br class="CLEAR" />
<img src="/Content/page_img/cart_content_bottom.gif" /></div>
</asp:Content>
